package com.sinoeyes.controller.agreement;

import com.sinoeyes.agreement.filter.AgreementFilter;
import com.sinoeyes.agreement.service.IAgreementService;
import com.sinoeyes.agreement.vo.AgreementQueryVO;
import com.sinoeyes.common.core.controller.BaseController;
import com.sinoeyes.common.core.page.RestPageResult;
import com.sinoeyes.common.result.R;
import com.sinoeyes.common.result.RCode;
import com.sinoeyes.common.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * 协议管理
 *
 * @author aries.hao
 */
@Slf4j
@RestController
@Api(value = "协议前后端分离接口", tags = {"协议管理"})
@RequestMapping("/agreement")
public class IAgreementController extends BaseController {

    private final IAgreementService agreementService;

    @Autowired
    public IAgreementController(IAgreementService agreementService) {
        this.agreementService = agreementService;
    }

    //    @RequiresPermissions("system:agreement:list")
    @PostMapping(value = "/getAgreementList")
    @ApiOperation(value = "获取协议基本信息")
    public Result<RestPageResult<AgreementQueryVO> > getAgreementList(@RequestBody(required = false) AgreementFilter agreementFilter) {
        RestPageResult<AgreementQueryVO> restPageResult = agreementService.selectAgreementList(agreementFilter);
        if (!ObjectUtils.isEmpty(restPageResult)) {
            return Result.success(restPageResult);
        }
        return Result.failure(RCode.NO_QUERY);
    }
}
